package com.le.tester.book.effectivejava3rdchinese.secondReading.l10;

import java.awt.*;
import java.util.Objects;

/**
 * createTime：2024-08-15 13:45
 * description：优先使用组合而不是继承
 */
public class SelfColorPoint {
    private final Point point;

    private final Color color;

    public SelfColorPoint(int x, int y, Color color) {

        point = new Point(x, y);
        this.color = Objects.requireNonNull(color);
    }

    public Point asPoint() {

        return point;
    }

    public boolean equals(Object o) {
        if (!(o instanceof SelfColorPoint)) {
            return false;
        }

        SelfColorPoint colorPoint = (SelfColorPoint) o;
        return colorPoint.point.equals(point) && colorPoint.color.equals(color);
    }
}
